﻿using Newtonsoft.Json;
using System;
using System.ComponentModel.DataAnnotations;
using VisionCloud.Core.Model.Enums;

namespace VisionCloud.Domain.File.Model
{
    public class PartUploadDto : UploadWithTaskInfo
    {
        /// <summary>
        /// 分块的序号，从 0 开始
        /// </summary>
        [Required]
        public int Index { get; set; }

        /// <summary>
        /// 分块的总数量，依据 chunkSize 计算
        /// </summary>
        public int TotalChunks { get; set; }

        /// <summary>
        /// 文件总大小
        /// </summary>
        public long TotalSize { get; set; }

        /// <summary>
        /// 分块大小，最后一块可能小于该值
        /// </summary>
        public long ChunkSize { get; set; }
    }

    public class UploadFileBaseDto
    {
        /// <summary>
        /// 前端计算号MD5值
        /// </summary>
        [Required]
        public string Identifier { get; set; }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string FileName { get; set; }
    }

    public class UploadWithTaskInfo : UploadFileBaseDto
    {
        /// <summary>
        /// 任务Id
        /// </summary>
        [Required]
        public Guid TaskId { get; set; }

        /// <summary>
        /// 测量站点编号
        /// </summary>
        [Required]
        public int PointIndex { get; set; }

        /// <summary>
        /// 上传批次Id
        /// </summary>
        public Guid? BatchId { get; set; }

        public MeasureTypeEnum? MeasureType { get; set; }
    }

    public class UploadWithFaroSN : UploadFileBaseDto
    {
        public string FaroSN { get; set; }
    }

    public class VerifyResponse
    {
        /// <summary>
        /// 存储文件的Url
        /// </summary>
        [JsonProperty("url")]
        public string Url { get; set; }

        /// <summary>
        /// 是否需要上传，用于秒传验证
        /// </summary>
        [JsonProperty("needUpload")]
        public bool NeedUpload { get; set; }

        /// <summary>
        /// 已上传的分片
        /// </summary>
        [JsonProperty("uploadedChunks")]
        public int[] UploadedChunks { get; set; }
    }

    public class MergeResponse
    {
        /// <summary>
        /// 存储文件的Url
        /// </summary>
        [JsonProperty("url")]
        public string Url { get; set; }
    }

    public class UploadResponse
    {
        /// <summary>
        /// 临时文件路径
        /// </summary>
        [JsonProperty("temFilePath")]
        public string TemFilePath { get; set; }
    }
}